package base.day21.MyHashSet2;

import base.day21.Student;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MyMap2 {
    public static void main(String[] args) {
        Map<Student,String> map=new HashMap<>();
        Student stu1=new Student("zhangsan",23);
        Student stu2=new Student("lisi",24);
        Student stu3=new Student("wangwu",25);
        Student stu4=new Student("zhaoliu",26);
        Student stu5=new Student("qinqi",27);

        map.put(stu1,"一号");
        map.put(stu2,"二号");
        map.put(stu3,"三号");
        map.put(stu4,"四号");
        map.put(stu5,"五号");

        Set<Map.Entry<Student, String>> entries = map.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+value);
        }
        System.out.println("-------------------------------");
        Set<Student> students = map.keySet();
        for (Student student : students) {
            String value = map.get(student);
            System.out.println(student+value);
        }
        System.out.println("-----------------------------------");
        map.forEach(
                (Student key,String value)->{
            System.out.println(key+value);
        });
    }
}
